import java.util.*;

public class C {
	public static void main(String[] args) {
		var sc = new Scanner(System.in);
		int n = sc.nextInt();
		// 直接写一个数组去模拟栈
		int[] q = new int[n + 10];
		int tt = 0; // 栈顶
		
		for(int i = 1; i <= n; i ++ ) {
			int x = sc.nextInt();
			if(tt == 0) {
				q[ ++ tt] = x; // 表示为空的 要直接去插进去
			} else {
				while(tt != 0 ) {
					int t = q[tt];
					tt -= 1; // 表示取了出来
					if(t == x) {
						x += 1; // 表示合并
					} else {
						q[++ tt] = t;
						q[++ tt] = x; // 这两个都插进去
						//System.out.print("tt = " + tt + " t = " + t + " x = " + x + "\n");
						break;
					}
				}
				if(tt == 0) {
					//System.out.print("i = " + i + "\n");
					q[++ tt] = x;
					//System.out.print("tt = " + tt + " x = " + x + "\n");
				}
			}
		}
		System.out.print(tt); // 里面元素的个数
	}
}
